//
//  MCBillListCell.swift
//  StoreManage
//
//  Created by MC on 2018/5/21.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

class MCBillListCell: UITableViewCell {

    var model = MCBillListModel() {
        didSet {
            timeLabel.text = model.date
            count_topLabel.text = model.count.stringValue
            money_topLabel.text = MCString_judgemantDecimalsIsZero(figure: model.money.intValue)
        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) -> Void in
            make.edges.equalTo(self).inset(UIEdgeInsetsMake(0, 0, 5, 0))
        }
        
        bgView.addSubview(lineView)
        lineView.snp.remakeConstraints { (make) -> Void in
            make.left.equalTo(bgView)
            make.right.equalTo(bgView)
            make.top.equalTo(bgView).offset(40)
            make.height.equalTo(1)
        }
        
        bgView.addSubview(timeLabel)
        timeLabel.snp.remakeConstraints { (make) -> Void in
            make.left.equalTo(bgView).offset(10)
            make.top.equalTo(bgView)
            make.bottom.equalTo(lineView.snp.top)
        }
        
        bgView.addSubview(count_topLabel)
        count_topLabel.snp.remakeConstraints { (make) -> Void in
            make.left.equalTo(bgView).offset(30)
            make.centerY.equalTo(bgView).offset(5)
        }
        
        bgView.addSubview(count_bottomLabel)
        count_bottomLabel.snp.remakeConstraints { (make) -> Void in
            make.centerX.equalTo(count_topLabel)
            make.top.equalTo(count_topLabel.snp.bottom).offset(10)
        }
        
        bgView.addSubview(money_topLabel)
        money_topLabel.snp.remakeConstraints { (make) -> Void in
            make.right.equalTo(lineView.snp.right).offset(-50)
            make.centerY.equalTo(count_topLabel)
        }
        
        bgView.addSubview(money_bottomLabel)
        money_bottomLabel.snp.remakeConstraints { (make) -> Void in
            make.centerX.equalTo(money_topLabel)
            make.top.equalTo(money_topLabel.snp.bottom).offset(10)
        }

        
        bgView.addSubview(arrowImageView)
        arrowImageView.snp.remakeConstraints { (make) ->Void in
            make.right.equalTo(bgView).offset(-10)
            make.centerY.equalTo(bgView.snp.bottom).offset(-55)
            make.size.equalTo(CGSize.init(width: 8, height: 14))
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy private var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        return view
    }()
    
    
    lazy private var timeLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(15)
        label.textColor = UIColor.black
        return label
    }()
    
    lazy private var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()

    lazy var arrowImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Reuse_arrow")
        return imageView
    }()
    
    lazy private var count_topLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(30)
        label.textColor = UIColor.black
        label.text = "0"
        return label
    }()
    
    lazy private var count_bottomLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(15)
        label.textColor = UIColor.MCGray
        label.text = "笔数"
        return label
    }()
    
    lazy private var money_topLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(30)
        label.textColor = UIColor.black
        label.text = "¥0"
        return label
    }()
    
    lazy private var money_bottomLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(15)
        label.textColor = UIColor.MCGray
        label.text = "金额"
        return label
    }()
    


}
